<template>
  <div class="son">
    <h2>孙组件</h2>
    <h4>银子: {{ x }}</h4>
    <h4>车: {{ y.brand }} {{ y.price }}</h4>
    <button @click="addMoney(10)">加钱</button>
  </div>
</template>

<script setup lang="ts">
  import { inject } from 'vue';
  let x = inject('qian', '默认值') // 前面不传的时候, 默认值才奏效
  let y = inject('che', {brand:'未知', price:0})
  let { money, addMoney } = inject('money',{money:0, addMoney:(x:number)=>{}})


</script>

<style scoped>
  .son {
    background: pink;
  }
</style>